home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / fpu881 / src6.zoo / ldexp.s < prev    next >
Text File  |  1991-09-24  |  1KB  |  55 lines

  1. # 1 "ldexp.cpp"
  2. # add exponent to floating point number
  3. # C Interface
  4. # double ldexp(double value, unsigned int exp);
  5. # returns value * 2**exp
  6. # (int is 16 bits if -mshort, 32 bits if !-mshort)
  7. # performed entirely on the 68881 to avoid overfow as good as possible
  8. ##############################################################################
  9. # hacked for the 68881 by Michael Ritzert, 5.10.90
  10. ##############################################################################
  11.  
  12. # addresses of the 68881 data port. This choice is fastest when much data is
  13. # transferred between the two processors.
  14.  
  15. comm =     -6    |    fpu command reg
  16. resp =    -16    |    fpu response reg
  17. zahl =      0    |    fpu data reg
  18.  
  19. # waiting loop ...
  20. #
  21. # wait:
  22. # ww:    cmpiw    #0x8900,a1@(resp)
  23. #     beq    ww
  24. # is coded directly by
  25. #    .byte    0x0c,0x69,0x89,0x00,0xff,0xf0,0x67,0xf8 (a1)
  26. #    or
  27. #    .long    0x0c6889000, 0x000067f8            (a0)
  28.  
  29.     .text; .even
  30.     .globl _ldexp
  31. _ldexp:
  32.     lea    0xfffa50,a0        | fpu address
  33.     movew    #0x4011,a0@(comm)    | ftwotox to fp0 (as long int!)
  34.  
  35.     movew    a7@(12),d0        | get exponent
  36.     extl    d0
  37.  
  38.  
  39.  
  40.     cmpiw    #0x8900,a0@(resp)    | check if fpu is ready
  41.     movel    d0,a0@            | push arg
  42.     .long    0x0c6889000, 0xfff067f8    | wait
  43.     movew    #0x5423,a0@(comm)    | fmul value,fp0
  44.     .long    0x0c6889000, 0xfff067f8    | wait
  45.     movel    a7@(4),a0@        | load value
  46.     movel    a7@(8),a0@        |
  47.     .long    0x0c6889000, 0xfff067f8    | wait
  48.     movew    #0x7400,a0@(comm)    | get double from fp0
  49.     .long    0x0c6889000, 0xfff067f8    | wait
  50.     movel    a0@,d0
  51.     movel    a0@,d1
  52.     rts
  53.  
  54.     
  55.